file(GLOB ABC_SOURCE *.cpp *.h)

target_sources(zeno PRIVATE ${ABC_SOURCE})
zeno_disable_warning(${ABC_SOURCE})

target_include_directories(zeno PRIVATE .)

option(ZENO_SYSTEM_ALEMBIC "Use Alembic found in system instead of submodule" OFF)
if (ZENO_SYSTEM_ALEMBIC)
    find_package(Alembic REQUIRED)
    target_link_libraries(zeno PRIVATE Alembic::Alembic)
else()
    if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Alembic/CMakeLists.txt)
        message(FATAL_ERROR "Alembic submodule not found! Please run: git submodule update --init --recursive")
    endif()
    #set(ALEMBIC_ILMBASE_LINK_STATIC ON CACHE BOOL FORCE "FKSTATIC")
    #set(ALEMBIC_SHARED_LIBS OFF CACHE BOOL FORCE "FKSTATIC")
    add_subdirectory(Alembic)
    target_link_libraries(zeno PRIVATE Alembic)
    #target_link_libraries(zeno PRIVATE Iex)
    #target_link_libraries(zeno PRIVATE Imath)
    #target_link_libraries(zeno PRIVATE IlmThread)
    #target_link_libraries(zeno PRIVATE OpenEXR)
    target_include_directories(zeno PRIVATE Alembic/openexr/src/lib/Iex)
    target_include_directories(zeno PRIVATE Alembic/openexr/src/lib/IlmThread)
    target_include_directories(zeno PRIVATE Alembic/openexr/src/lib/OpenEXR)
    target_include_directories(zeno PRIVATE Alembic/openexr/src/lib/OpenEXRCore)
    target_include_directories(zeno PRIVATE Alembic/openexr/src/lib/OpenEXRUtil)
    target_include_directories(zeno PRIVATE Alembic/openexr/Imath/src/Imath)
    target_include_directories(zeno PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/Alembic/openexr/Imath/config)
endif()

find_package(PNG REQUIRED)
target_link_libraries(zeno PRIVATE PNG::PNG)

if (ZENO_WITH_PYTHON3)
    find_package(Python3 COMPONENTS Development REQUIRED)
    target_compile_definitions(zeno PRIVATE -DZENO_WITH_PYTHON3)
    target_link_libraries(zeno PRIVATE ${Python3_LIBRARIES})
    target_include_directories(zeno PRIVATE ${Python3_INCLUDE_DIRS})
endif()
